<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/common/head.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">

<title>编辑公告</title>
<link href="${resource }/css/bootstrap.css" rel="stylesheet">
<link href="${resource }/font-awesome/css/font-awesome.css?v=4.3.0"
	rel="stylesheet">
<link href="${resource }/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="${resource }/css/animate.css" rel="stylesheet">
<!--富文本编辑器-->
<link rel="stylesheet" type="text/css"
	href="${resource }/css/plugins/simditor/simditor.css" />
<!--webuploader-->
<link rel="stylesheet" type="text/css"
	href="${resource }/css/plugins/webuploader/webuploader.css">
<link rel="stylesheet" type="text/css"
	href="${resource }/css/demo/webuploader-demo.css">
<link href="${resource }/css/style.css?v=2.2.0" rel="stylesheet">
<link rel="stylesheet" href="${resource }/css/notices.css" />
</head>

<body>
	<div class="row wrapper border-bottom white-bg page-heading">
		<div class="col-lg-10">
			<h2>编辑公告</h2>
			<ol class="breadcrumb">
				<li><a href="index.html">主页</a></li>
				<li><a>编辑公告</a></li>
			</ol>
		</div>
		<div class="col-lg-2"></div>
	</div>
	<div class="row wrapper border-bottom white-bg page-heading">
		<div class="row">
			<div class="col-lg-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>
							公告 <small>编辑公告</small>
						</h5>
						<div class="ibox-tools">
							<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
							</a> <a class="dropdown-toggle" data-toggle="dropdown"
								href="form_basic.html#"> <i class="fa fa-wrench"></i>
							</a> <a class="close-link"> <i class="fa fa-times"></i>
							</a>
						</div>
					</div>
					<div class="ibox-content">
						<!-- 	<form action="saveEdit.do" method="get" class="form-horizontal"> -->
						<div class="form-horizontal">
							<div class="form-group">
								<label class="col-sm-2 control-label">标题</label>

								<div class="col-sm-10">
									<input type="text" class="form-control"
										value="${notice.noticeTitle }" id="noticeTitle">
								</div>
							</div>
							<!--
											作者：985379016@qq.com
											时间：2018-08-21
											描述：富文本编辑器
										-->

							<div class="col-lg-12">
								<div class="ibox float-e-margins">
									<div class="ibox-title">
										<h5>内容</h5>
										<div class="ibox-tools">
											<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
											</a> <a class="close-link"> <i class="fa fa-times"></i>
											</a>
										</div>
									</div>
									<div class="ibox-content">
										<textarea id="editor">
									    	${notice.noticeInfo }                     
		                               </textarea>
									</div>
								</div>
							</div>

							<!--
											作者：985379016@qq.com
											时间：2018-08-21
											描述：web uploader
										-->
							<div class="row">
								<div class="col-lg-12">
									<div class="ibox float-e-margins">
										<div class="ibox-title">
											<h5>附件</h5>
											<div class="ibox-tools">
												<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
												</a> <a class="close-link"> <i class="fa fa-times"></i>
												</a>
											</div>
										</div>
										<div class="ibox-content">
											<div class="page-container">
												<p>您可以尝试文件拖拽，使用QQ截屏工具，然后激活窗口后粘贴，或者点击添加图片按钮，来上传附件</p>
												<div id="uploader" class="wu-example">
													<div class="queueList">
														<div id="dndArea" class="placeholder">
															<div id="filePicker"></div>
															<p>或将照片拖到这里，单次最多可选300张</p>
														</div>
													</div>
													<div class="statusBar" style="display: none;">
														<div class="progress">
															<span class="text">0%</span> <span class="percentage"></span>
														</div>
														<div class="info"></div>
														<div class="btns">
															<div id="filePicker2"></div>
															<div class="uploadBtn">开始上传</div>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">状态</label>
								<div class="col-sm-10">
									<select class="form-control m-b" name="isPublish"
										id="isPublish">
										<c:if test="${notice.isPublish==1 }">
											<option selected="selected">已发布</option>
											<option>待发布</option>
										</c:if>
										<c:if test="${notice.isPublish==0 }">
											<option selected="selected">待发布</option>
											<option>已发布</option>
										</c:if>
									</select>
								</div>
							</div>
							<div class="hr-line-dashed"></div>
							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-2">
									<button id="save" class="btn btn-primary" type="button">保存内容</button>
									<button id="cancle" class="btn btn-white" type="button">取消</button>
								</div>
							</div>
						</div>
						<!-- 		</form> -->
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- Mainly scripts -->
	<script src="${resource }/js/jquery-2.1.1.min.js"></script>
	<script src="${resource }/js/bootstrap.min.js?v=3.4.0"></script>
	<script src="${resource }/js/plugins/metisMenu/jquery.metisMenu.js"></script>
	<script
		src="${resource }/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
	<!-- Custom and plugin javascript -->
	<script src="${resource }/js/hplus.js?v=2.2.0"></script>
	<script src="${resource }/js/plugins/pace/pace.min.js"></script>
	<!-- iCheck -->
	<script src="${resource }/js/plugins/iCheck/icheck.min.js"></script>
	<!-- simditor -->
	<script type="text/javascript"
		src="${resource }/js/plugins/simditor/module.js"></script>
	<script type="text/javascript"
		src="${resource }/js/plugins/simditor/uploader.js"></script>
	<script type="text/javascript"
		src="${resource }/js/plugins/simditor/hotkeys.js"></script>
	<script type="text/javascript"
		src="${resource }/js/plugins/simditor/simditor.js"></script>

	<script type="text/javascript" src="${resource }/js/editNotice.js"></script>
	<script>
		$(document).ready(function() {
			$('.i-checks').iCheck({
				checkboxClass : 'icheckbox_square-green',
				radioClass : 'iradio_square-green',
			});
		});
	</script>
	<script>
		$(document).ready(function() {
			var editor = new Simditor({
				textarea : $('#editor'),
			});
		});
	</script>
	<!--  用来实现点击保存后判断是否填写信息 以及使用ajax提交数据 同时接受返回值 实现跳转 -->
	<script type="text/javascript">
		$("#save")
				.click(
						function() {
							var noticeId = ${noticeid};
							var noticeInfo = document.getElementById("editor").value;
							var noticeTitle = document.getElementById("noticeTitle").value;
							var isPublish = document.getElementById("isPublish").value;
							var bool = confirm("确认保存吗");
							if (bool) {
								$.ajax({
											type : "POST",
											url : "saveEdit.do",
											data : "noticeInfo=" + noticeInfo
													+ "&noticeTitle="
													+ noticeTitle
													+ "&isPublish=" + isPublish
													+ "&noticeId=" + noticeId,
											success : function(data) {
												if (data == "success") {
													alert("修改成功,点击跳转所有公告");
													window.location = "showAllNotice.do"
												} else if (data == "false") {
													alert("修改失败,请稍后重试");
													window.location = "editNotice.do"
												}
											},
										});
							};
							return bool;
						});
	</script>
	<!-- Web Uploader -->
	<script type="text/javascript">
		// 添加全局站点信息
		var BASE_URL = '${resource }/js/plugins/webuploader';
	</script>
	<script src="${resource }/js/plugins/webuploader/webuploader.min.js"></script>
	<script src="${resource }/js/demo/webuploader-demo.js"></script>


</body>

</html>